home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch01 / reg8514a.h < prev    next >
Text File  |  1993-12-06  |  9KB  |  366 lines

  1. /*
  2.     REG8514.H
  3.  
  4.    Written by Jake Richter
  5.    Copyright (c) 1989,1990 Panacea Inc., Londonderry, NH - All Rights Reserved
  6.  
  7.    This code may be freely incorporated in any program without
  8.    royalty, as long as the copyright notice stays intact.
  9.  
  10.     This include file contains the standard definitions necessary for
  11.    programming the IBM 8514/A.
  12.  
  13.     The following definitions are used in all the listings to reference
  14.    certain data types. This is done to help make the code more readable,
  15.    and to assist later translation and communication with assembly language.
  16. */
  17.  
  18. /*
  19.    VESA Approved Register Definitions
  20. */
  21. #define  DAC_MASK    0x02EA
  22. #define  DAC_R_INDEX    0x02EB
  23. #define  DAC_W_INDEX    0x02EC
  24. #define  DAC_DATA    0x02ED
  25. #define  DISP_STAT    0x02E8
  26. #define  H_TOTAL    0x02E8
  27. #define  H_DISP        0x06E8
  28. #define  H_SYNC_STRT    0x0AE8
  29. #define  H_SYNC_WID    0x0EE8
  30. #define  V_TOTAL    0x12E8
  31. #define  V_DISP        0x16E8
  32. #define  V_SYNC_STRT    0x1AE8
  33. #define  V_SYNC_WID    0x1EE8
  34. #define  DISP_CNTL    0x22E8
  35. #define  ADVFUNC_CNTL    0x4AE8
  36. #define  SUBSYS_STAT    0x42E8
  37. #define  SUBSYS_CNTL    0x42E8
  38. #define  ROM_PAGE_SEL    0x46E8
  39. #define  CUR_Y        0x82E8
  40. #define  CUR_X        0x86E8
  41. #define  DESTY_AXSTP    0x8AE8
  42. #define  DESTX_DIASTP    0x8EE8
  43. #define  ERR_TERM    0x92E8
  44. #define  MAJ_AXIS_PCNT  0x96E8
  45. #define  GP_STAT    0x9AE8
  46. #define  CMD        0x9AE8
  47. #define  SHORT_STROKE    0x9EE8
  48. #define  BKGD_COLOR    0xA2E8
  49. #define  FRGD_COLOR    0xA6E8
  50. #define  WRT_MASK    0xAAE8
  51. #define  RD_MASK    0xAEE8
  52. #define  COLOR_CMP    0xB2E8
  53. #define  BKGD_MIX    0xB6E8
  54. #define  FRGD_MIX    0xBAE8
  55. #define  MULTIFUNC_CNTL 0xBEE8
  56. #define  MIN_AXIS_PCNT  0x0000
  57. #define  SCISSORS_T    0x1000
  58. #define  SCISSORS_L    0x2000
  59. #define  SCISSORS_B    0x3000
  60. #define  SCISSORS_R    0x4000
  61. #define  MEM_CNTL    0x5000
  62. #define  PATTERN_L    0x8000
  63. #define  PATTERN_H    0x9000
  64. #define  PIX_CNTL    0xA000
  65. #define  PIX_TRANS    0xE2E8
  66.  
  67. /* Display Status Bit Fields */
  68. #define  HORTOG        0x0004
  69. #define  VBLANK        0x0002
  70. #define  SENSE        0x0001
  71.  
  72. /* Horizontal Sync Width Bit Field */
  73. #define  HSYNCPOL_NEG    0x0020
  74. #define  HSYNCPOL_POS    0x0000
  75.  
  76. /* Vertical Sync Width Bit Field */
  77. #define  VSYNCPOL_NEG    0x0020
  78. #define  VSYNCPOL_POS    0x0000
  79.  
  80. /* Display Control Bit Field */
  81. #define  DISPEN_NC    0x0000
  82. #define  DISPEN_DISAB    0x0040
  83. #define  DISPEN_ENAB    0x0020
  84. #define  INTERLACE    0x0010
  85. #define  DBLSCAN    0x0008
  86. #define  MEMCFG_2    0x0000
  87. #define  MEMCFG_4    0x0002
  88. #define  MEMCFG_6    0x0004
  89. #define  MEMCFG_8    0x0006
  90. #define  ODDBNKENAB    0x0001
  91.  
  92. /* Subsystem Status Register */
  93. #define  _8PLANE    0x0080
  94. #define  MONITORID_8503 0x0050
  95. #define  MONITORID_8507 0x0010
  96. #define  MONITORID_8512 0x0060
  97. #define  MONITORID_8513 0x0060
  98. #define  MONITORID_8514 0x0020
  99. #define  MONITORID_NONE 0x0070
  100. #define  MONITORID_MASK 0x0070
  101. #define  GPIDLE        0x0008
  102. #define  INVALIDIO    0x0004
  103. #define  PICKFLAG    0x0002
  104. #define  VBLNKFLG    0x0001
  105.  
  106. /* Subsystem Control Register */
  107. #define  GPCTRL_NC    0x0000
  108. #define  GPCTRL_ENAB    0x4000
  109. #define  GPCTRL_RESET    0x8000
  110. #define  CHPTEST_NC    0x0000
  111. #define  CHPTEST_NORMAL 0x1000
  112. #define  CHPTEST_ENAB    0x2000
  113. #define  IGPIDLE    0x0800
  114. #define  IINVALIDIO    0x0400
  115. #define  IPICKFLAG    0x0200
  116. #define  IVBLNKFLG    0x0100
  117. #define  RGPIDLE    0x0008
  118. #define  RINVALIDIO    0x0004
  119. #define  RPICKFLAG    0x0002
  120. #define  RVBLNKFLG    0x0001
  121.  
  122. /* Current X, Y & Dest X, Y Mask */
  123. #define  COORD_MASK    0x07FF
  124.  
  125. /* Advanced Function Control Register */
  126. #define  CLKSEL        0x0004
  127. #define  DISABPASSTHRU  0x0001
  128.  
  129. /* Graphics Processor Status Register */
  130. #define  GPBUSY        0x0200
  131. #define  DATARDY    0x0100
  132.  
  133. /* Command Register */
  134. #define  CMD_NOP    0x0000
  135. #define  CMD_LINE    0x2000
  136. #define  CMD_RECT    0x4000
  137. #define  CMD_RECTV1    0x6000
  138. #define  CMD_RECTV2    0x8000
  139. #define  CMD_LINEAF    0xA000
  140. #define  CMD_BITBLT    0xC000
  141. #define  CMD_OP_MSK    0xF000
  142. #define  BYTSEQ        0x1000
  143. #define  _16BIT        0x0200
  144. #define  PCDATA        0x0100
  145. #define  INC_Y        0x0080
  146. #define  YMAJAXIS    0x0040
  147. #define  INC_X        0x0020
  148. #define  DRAW        0x0010
  149. #define  LINETYPE    0x0008
  150. #define  LASTPIX    0x0004
  151. #define  PLANAR        0x0002
  152. #define  WRTDATA    0x0001
  153.  
  154. /*
  155.    Short Stroke Vector Transfer Register
  156.    (The angular defs also apply to the Command Register)
  157. */
  158. #define  VECDIR_000    0x0000
  159. #define  VECDIR_045    0x0020
  160. #define  VECDIR_090    0x0040
  161. #define  VECDIR_135    0x0060
  162. #define  VECDIR_180    0x0080
  163. #define  VECDIR_225    0x00A0
  164. #define  VECDIR_270    0x00C0
  165. #define  VECDIR_315    0x00E0
  166. #define  SSVDRAW    0x0010
  167.  
  168. /* Background Mix Register */
  169. #define  BSS_BKGDCOL    0x0000
  170. #define  BSS_FRGDCOL    0x0020
  171. #define  BSS_PCDATA    0x0040
  172. #define  BSS_BITBLT    0x0060
  173.  
  174. /* Foreground Mix Register */
  175. #define  FSS_BKGDCOL    0x0000
  176. #define  FSS_FRGDCOL    0x0020
  177. #define  FSS_PCDATA    0x0040
  178. #define  FSS_BITBLT    0x0060
  179.  
  180. /*
  181.    The Mixes (Note that some are duplicated for ease
  182.    of use.
  183. */
  184. #define  MIX_MASK             0x001F
  185.  
  186. #define  MIX_NOT_DST             0x0000
  187. #define  MIX_0                 0x0001
  188. #define  MIX_1                 0x0002
  189.  
  190. #define  MIX_DST             0x0003
  191. #define  MIX_LEAVE_ALONE         0x0003
  192.  
  193. #define  MIX_NOT_SRC             0x0004
  194.  
  195. #define  MIX_SRC_XOR_DST         0x0005
  196. #define  MIX_XOR             0x0005
  197.  
  198. #define  MIX_NOT__SRC_XOR_DST         0x0006
  199. #define  MIX_XNOR             0x0006
  200.  
  201. #define  MIX_SRC             0x0007
  202. #define  MIX_REPLACE             0x0007
  203. #define  MIX_PAINT             0x0007
  204.  
  205. #define  MIX_NOT_SRC_OR_NOT_DST         0x0008
  206. #define  MIX_NAND             0x0008
  207.  
  208. #define  MIX_NOT_SRC_OR_DST         0x0009
  209. #define  MIX_SRC_OR_NOT_DST         0x000A
  210.  
  211. #define  MIX_SRC_OR_DST             0x000B
  212. #define  MIX_OR                 0x000B
  213.  
  214. #define  MIX_SRC_AND_DST         0x000C
  215. #define  MIX_AND             0x000C
  216.  
  217. #define  MIX_SRC_AND_NOT_DST         0x000D
  218. #define  MIX_NOT_SRC_AND_DST         0x000E
  219.  
  220. #define  MIX_NOT_SRC_AND_NOT_DST     0x000F
  221. #define  MIX_NOR             0x000F
  222.  
  223. #define  MIX_MIN             0x0010
  224. #define  MIX_DST_MINUS_SRC         0x0011
  225. #define  MIX_SRC_MINUS_DST         0x0012
  226. #define  MIX_PLUS             0x0013
  227. #define  MIX_MAX             0x0014
  228. #define  MIX_HALF__DST_MINUS_SRC     0x0015
  229. #define  MIX_HALF__SRC_MINUS_DST     0x0016
  230. #define  MIX_AVERAGE             0x0017
  231. #define  MIX_DST_MINUS_SRC_SAT         0x0018
  232. #define  MIX_SRC_MINUS_DST_SAT         0x001A
  233. #define  MIX_PLUS_SAT             0x001B
  234. #define  MIX_HALF__DST_MINUS_SRC_SAT 0x001C
  235. #define  MIX_HALF__SRC_MINUS_DST_SAT 0x001E
  236. #define  MIX_AVERAGE_SAT         0x001F
  237.  
  238. /* Memory Control Register */
  239. #define  BUFSWP        0x0010
  240. #define  VRTCFG_2    0x0000
  241. #define  VRTCFG_4    0x0004
  242. #define  VRTCFG_6    0x0008
  243. #define  VRTCFG_8    0x000C
  244. #define  HORCFG_4    0x0000
  245. #define  HORCFG_5    0x0001
  246. #define  HORCFG_8    0x0002
  247. #define  HORCFG_10    0x0003
  248.  
  249. /* Pixel Control Register */
  250. #define  MIXSEL_FRGDMIX 0x0000
  251. #define  MIXSEL_PATT    0x0040
  252. #define  MIXSEL_EXPPC    0x0080
  253. #define  MIXSEL_EXPBLT  0x00C0
  254. #define  COLCMPOP_F    0x0000
  255. #define  COLCMPOP_T    0x0008
  256. #define  COLCMPOP_GE    0x0010
  257. #define  COLCMPOP_LT    0x0018
  258. #define  COLCMPOP_NE    0x0020
  259. #define  COLCMPOP_EQ    0x0028
  260. #define  COLCMPOP_LE    0x0030
  261. #define  COLCMPOP_GT    0x0038
  262. #define  PLANEMODE    0x0004
  263.  
  264.  
  265. /*
  266.      This makes it easier to use the palette.
  267. */
  268. typedef struct {
  269.     unsigned char r;
  270.     unsigned char g;
  271.     unsigned char b;
  272. } LUTENTRY;
  273.  
  274. /*
  275.      Macro to aid in waiting for the command queue to empty.
  276.      The parameter 'v' specifies the number of queue entries
  277.      that you are waiting to be free.
  278. */
  279. #define  WaitQueue(v)    {while (inpw(GP_STAT) & (0x0100 >> (v)));}
  280. #define  WaitBusy()    {while (inpw(GP_STAT) & GPBUSY); }
  281.  
  282. /*
  283.  * missing "in" and "out" stuff for various compilers
  284.  */
  285.  
  286. #ifdef __TURBOC__
  287. /*
  288.  * TCC has byte size "inp" and "outp"
  289.  */
  290. #pragma inline
  291.  
  292. #define outpw(port,value) do {                \
  293.     _AX = (value);                    \
  294.     _DX = (port);                    \
  295.     asm out dx,ax;                    \
  296. } while(0)
  297.  
  298. static int inpw(int port)
  299. {
  300.     _DX = port;
  301.     asm in  ax,dx;
  302.     return(_AX);
  303. }
  304.  
  305. #endif /* __TURBOC__ */
  306.  
  307. #ifdef __GNUC__
  308. /*
  309.  * gcc needs both byte and word size ones
  310.  */
  311.  
  312. #define outp(port,value) do {                \
  313.     asm volatile("                                    \n\
  314.     movl    %1,%%eax                  \n\
  315.     movl    %0,%%edx                  \n\
  316.     outb    %%al,%%dx                   "\
  317.     : /* no output */                \
  318.     : "g" (port), "g" (value)            \
  319.     : "ax", "dx"                    \
  320.     );                            \
  321. } while(0)
  322.  
  323. #define outpw(port,value) do {                \
  324.     asm volatile("                                    \n\
  325.     movl    %1,%%eax                  \n\
  326.     movl    %0,%%edx                  \n\
  327.     outw    %%ax,%%dx                   "\
  328.     : /* no output */                \
  329.     : "g" (port), "g" (value)            \
  330.     : "ax", "dx"                    \
  331.     );                            \
  332. } while(0)
  333.  
  334. static inline int inp(int port)
  335. {
  336.     register int value;
  337.  
  338.     asm volatile("                                \n\
  339.         movl    %1,%%edx                  \n\
  340.         inb        %%dx,%%al                  \n\
  341.         movzbl  %%al,%0                   "\
  342.         : "=g" (value)                \
  343.         : "g" (port)                \
  344.         : "ax", "dx"                \
  345.     );
  346.     return(value);
  347. }
  348.  
  349. static inline int inpw(int port)
  350. {
  351.     register int value;
  352.  
  353.     asm volatile("                                \n\
  354.         movl    %1,%%edx                  \n\
  355.         inw        %%dx,%%ax                  \n\
  356.         movzwl  %%ax,%0                   "\
  357.         : "=g" (value)                \
  358.         : "g" (port)                \
  359.         : "ax", "dx"                \
  360.     );
  361.     return(value);
  362. }
  363.  
  364. #endif /* __GCC__ */
  365.  
  366.